package model;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Bateau 
{
	private bddConnection connection;
	private int bateau_id;
	private int position_x;
	private int position_y;
	private String nom;
	private int est_eau;
	
	public Bateau( int bateau_id, bddConnection connection) throws SQLException
	{
		this.connection = connection;
		this.bateau_id = bateau_id;
		this.setInfo();
	}
	
	public void setInfo() throws SQLException
	{
		ResultSet rs = this.connection.doSql("select bateau.id, nom, est_eau, position_x, position_y " +
				"from bateau LEFT OUTER JOIN coordonnee ON bateau.coordonnee_id = coordonnee.id " +
				"where bateau.id = " + this.bateau_id);
		while(rs.next())
		{
			this.position_x = rs.getInt("position_x");
			this.position_y = rs.getInt("position_y");
			this.nom = rs.getString("nom");
			this.est_eau = rs.getInt("est_eau");
		}	
	}

	public int getBateau_id() {
		return bateau_id;
	}

	public void setBateau_id(int bateau_id) {
		this.bateau_id = bateau_id;
	}

	public int getPosition_x() {
		return position_x;
	}

	public void setPosition_x(int position_x) {
		this.position_x = position_x;
	}

	public int getPosition_y() {
		return position_y;
	}

	public void setPosition_y(int position_y) {
		this.position_y = position_y;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public int getEst_eau() {
		return est_eau;
	}

	public void setEst_eau(int est_eau) {
		this.est_eau = est_eau;
	}
	
	

}
